<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:t="http://www.w3.org/1999/xhtml">
<head th:replace="components/easyui/easyui-list :: head('新闻', 'easyui,upload,ueditor')">
<body>
<form id="form_add">
        <div>
            <input class="easyui-textbox" id="add_title" name="title" data-options="label:'标题:', width:300, required:true">
        </div>
        <div>
            <t:dict class="easyui-combobox" id="add_status" name="status" dict-name="news_status" data-options="label:'状态:', width:300, multiple:false"></t:dict>
        </div>
        <div>
            <label style="width: 80px;float:left;">新闻内容:</label>
            <div id="add_content_editor" type="text/plain" style="width:80%;height:400px;float:left;"></div>
            <div style="clear:both"></div>
        </div>
        <div>
            <label style="width: 80px;float:left;">缩略图:</label>
            <div th:replace="components/toolbar :: file-upload (idVal='add_imageUrl',nameVal='imageUrl')" style="width:94%;float:left;"></div>
            <div style="clear:both"></div>
        </div>
        <div>
            <input class="easyui-datetimebox" id="add_publishDate" name="publishDate" data-options="label:'发布时间:', width:300, required:true">
        </div>
        <div>
            <input class="easyui-textbox" id="add_tags" name="tags" data-options="label:'标签:', width:300, required:true">
        </div>
        <div>
            <t:dict class="easyui-combobox" id="add_newsType" name="newsType" dict-name="news_status" data-options="label:'新闻类型:', width:300, multiple:false"></t:dict>
        </div>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton c-primary" style="width:80px" onclick="add()" th:text="#{ok}"></a>
        <a href="javascript:void(0)" class="easyui-linkbutton c-basic" style="width:80px" onclick="clearForm()" th:text="#{cancel}"></a>
    </div>
</form>
<div id="dlg" class="easyui-dialog" data-options="title:'图片信息',closed:true" style="width:480px;height:480px;padding:10px"></div>
<div id="window_content" class="easyui-window" title="内容详情" data-options="modal:true,closed:true,collapsible:false" style="width:720px;height:480px;padding:10px;"></div>
<div th:replace="components/easyui/easyui-list :: js('easyui,upload,ueditor')"></div>
<script th:inline="javascript">
    /*<![CDATA[*/
    $(function () {
        //实例化编辑器
        //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
        /*var addEditor = UE.getEditor('add_editor', {
            autoHeight: false
        });*/
        var contentEditor = UE.getEditor('add_content_editor', {
            autoHeight: false
        });
        //初始化图片上传按钮
        initFileUpload('#add_imageUrl', 'imageUrl');
    });

    function add() {
        doRequest({
            formId: '#form_add',
            url: '/api/newsInfos/add',
            type: 'POST',
            extraData: {
                content: UE.getEditor('add_content_editor').getContent(),
            }
        });
    }

    function clearForm() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    /*]]>*/
</script>
</body>
</html>